//1.引入Vue
import Vue from 'vue';

//2.引入vue-router
import VueRouter from 'vue-router';

//引入路由组件
import Home from '../pages/Home';
import Login from '../pages/Login';
import Music from '../pages/Home/Music';
import News from '../pages/Home/News';
import Games from '../pages/Home/Games'

//3.使用VueRouter插件
Vue.use(VueRouter)

//4.创建路由器对象
export default new VueRouter({
    routes:[
        {path:'/login',component:Login},
        {path:'/home',component:Home,children:[
            {path:'news',component:News,name:'news'},
            {path:'music/:id',component:Music,name:'music',props:true},
            {path:'games',component:Games,name:'games',
            // props:{
            //     a:1,
            //     b:2
            // }
            props(route){
                return route.query
            }
        },
            //子路由重定向
            {path:'',redirect:'news'}
        ]},
        //重定向
        {path:'/',redirect:'home'}
    ]
})